package com.hfy.kandian.controller;


import com.hfy.kandian.dao.representation.BookRepresentation;
import com.hfy.kandian.entity.Book;
import com.hfy.kandian.service.BookshelfService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author HAN XIAOYANG
 * @since 2020-12-30
 */
@RestController
@RequestMapping("/bookshelf")
public class BookshelfController {
    @Autowired
    private BookshelfService bookshelfService;

    @ApiOperation(value = "查看该书籍是否被收藏")
    @GetMapping("/isCollected/{userId}/{bookId}")
    public int isCollected(@PathVariable int userId,@PathVariable int bookId){
        return bookshelfService.isCollected(userId,bookId);
    }

    @ApiOperation(value = "收藏书籍")
    @GetMapping("/collecte/{userId}/{bookId}")
    public int collecte(@PathVariable int userId,@PathVariable int bookId){
        return bookshelfService.collect(userId,bookId);
    }

    @ApiOperation(value = "取消收藏书籍")
    @GetMapping("/delete/{userId}/{bookId}")
    public int delete(@PathVariable int userId,@PathVariable int bookId){
        return bookshelfService.delete(userId,bookId);
    }

    @ApiOperation(value = "查看所有收藏的书籍ID")
    @GetMapping("/show/{userId}")
    public List<Integer> show(@PathVariable int userId){
        return bookshelfService.show(userId);
    }


}

